package com.competition.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.competition.dao.AgriculturalTrainingDao;
import com.competition.dao.AgriculturalTrainingDetailDao;
import com.competition.entity.AgriculturalTraining;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface AgriculturalTrainingMapper extends BaseMapper<AgriculturalTraining> {
    @Select("select agricultural_training_detail.`training_detail_address`,agricultural_training.`agricultural_training_title`,agricultural_training.`agricultural_training_img`,agricultural_training.`agricultural_training_id`\n" +
            ",agricultural_training.`agricultural_training_count`,agricultural_training.`agricultural_training_price`\n" +
            " from agricultural_training_detail,agricultural_training where agricultural_training.`agricultural_training_id` = agricultural_training_detail.`agricultural_training_id`" +
            "LIMIT #{current},5")
    List<AgriculturalTrainingDao> getAllAgriculturalTrainingDao(@Param("current")int current);

    @Select("SELECT agricultural_training_detail.`training_detail_address`,agricultural_training.`agricultural_training_title`,agricultural_training.`agricultural_training_img`,agricultural_training.`agricultural_training_id`\n" +
            ",agricultural_training.`agricultural_training_count`,agricultural_training.`agricultural_training_price`,agricultural_training_detail.`training_detail_introduce`,\n" +
            "agricultural_training_detail.`training_detail_type`,agricultural_training_detail.`training_detail_time`\n" +
            " FROM agricultural_training_detail,agricultural_training WHERE agricultural_training.`agricultural_training_id` = agricultural_training_detail.`agricultural_training_id`" +
            "and agricultural_training.`agricultural_training_id` = #{id}")
    AgriculturalTrainingDetailDao getOneDeatil(@Param("id")String id);
}
